
{extend name='public/base' /}

{block name="content"}

<div class="layui-col-md12">
    <div class="layui-card">
        <div class="layui-card-body">
            <form action="" class="layui-form" method="get">
                <div class="layui-form-item layui-form-pane">

                    <div class="layui-inline">
                        <label class="layui-form-label">商户编号 ：</label>
                        <div class="layui-input-inline">
                            <input name="merchant_sn" class="layui-input" id="title" value="" type="text" placeholder="请输入商户编号">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">商户名称 ：</label>
                        <div class="layui-input-inline">
                            <input name="name" class="layui-input"  value="" type="text" placeholder="请输入商户名称">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">公司名称 ：</label>
                        <div class="layui-input-inline">
                            <input name="company" class="layui-input" value="" type="text" placeholder="请输入公司名称">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button class="layui-btn icon-btn layui-btn-sm" data-id="table_id" lay-filter="search" lay-submit="">
                            <i class="layui-icon"></i>搜索
                        </button>
                        <button type="reset" class="layui-btn icon-btn layui-btn-normal layui-btn-sm"><i class="layui-icon layui-icon-refresh"></i>{:__('Reset')}</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <div class="layui-card">
        <div class="layui-card-body">
            <table class="layui-hide" id="table_id" lay-filter="table_id"></table>
        </div>
    </div>

</div>
{/block}
{block name="js"} <!--js处理区-->
<script type="text/html" id="toolbarDemo">
    <div class="layui-btn-container">
        <button type="button" lay-event="add"  class="layui-btn {:node('Admin/addAdmin')} layui-btn-sm">添加商户</button>
        <button type="button" lay-event="del"  class="layui-btn {:node('Admin/del')} layui-btn-sm layui-btn-danger">冻结商户</button>
        <button type="button" lay-event="reload"  class="layui-btn  layui-btn-sm  layui-btn-primary">刷新表格</button>
    </div>
</script>


<script type="text/html" id="operationTpl">
    <a href="javascript:;" class="layui-btn layui-btn-primary  layui-btn-xs {:node('Admin/addAdmin')}" data-title="积分变动" lay-event="balance"><i class="layui-icon-edge"></i></a>
    <a href="javascript:;" class="layui-btn layui-btn-normal layui-btn-xs {:node('Admin/addAdmin')}" data-title="编辑" lay-event="edit"><i class="layui-icon"></i></a>
    <a href="javascript:;" class="layui-btn layui-btn-danger layui-btn-xs {:node('Admin/del')}" data-title="删除" lay-event="del"><i class="layui-icon "></i></a>
</script>

<script>
    layui.use(['element', 'table', 'form', 'jquery', 'lucky','opTable'], function () {
        var element = layui.element;
        var form = layui.form;
        var table = layui.table;
        var $ = layui.jquery;
        var lucky=layui.lucky;
        var opTable = layui.opTable;
        form.render();

        var myTables = table.render({
            elem: '#table_id',
            url:"{:url('index')}",
            toolbar: '#toolbarDemo', //开启头部工具栏，并为其绑定左侧模板
            defaultToolbar: ['filter', 'exports', 'print'],
            even: true, //开启隔行背景
            id:'table_id',
            page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                layout: ['limit', 'count', 'prev', 'page', 'next', 'skip','last'] //自定义分页布局
                ,groups: 5 //只显示 1 个连续页码
                ,first: false //不显示首页
                ,last: false //不显示尾页
                ,limit:20
                ,limits:[10,20,30,50]
            },
              // height: 'full-100',100',
            text: {
                none: '暂无相关数据'
            },
            cols: [[
                { title: '', type: 'checkbox', fixed: true},
                { title: 'UID', field: 'id'},
                { title: '反馈者手机号码', field: 'mobile'},
                { title: '反馈主题', field: 'title', edit: 'text'},
                { title: '反馈明细', field: 'detail', edit: 'text'},
                { title: '处理状态', field: 'status', edit: 'text'},
                { title: '反馈时间', field: 'create_time',templet:function (item){
                        var date = new Date(parseInt(item.create_time) * 1000);
                        Y = date.getFullYear() + '-';
                        M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
                        D = date.getDate() + ' ';
                        h = (date.getHours()< 10 ? '0'+date.getHours() : date.getHours()) + ':';
                        m = (date.getMinutes()< 10 ? '0'+date.getMinutes() : date.getMinutes()) + ':';
                        s = (date.getSeconds()< 10 ? '0'+date.getSeconds() : date.getSeconds());
                        return Y+M+D+h+m+s;
                    }},
                {templet: '#operationTpl', width: 160, align: 'center', title: '操作'}
            ]],
            //  展开的列配置
            openCols: [
                {field: 'desc', title: '描述信息'}
            ],
            done: function (res) {
                layer.closeAll('loading');
            }
        });


        /**
         * 监听单行工具操作
         */
        table.on('tool(table_id)', function (obj) {
            var data = obj.data;
            var _id=parseInt(data.id);
            var layEvent = obj.event;
            if(layEvent==="edit"){
                var urls="{:url('add')}?id="+_id;
                lucky.CreateOpenForm("编辑商户",urls);

            }else if(layEvent==="del"){
                lucky.FormatData(_id,"{:url('del')}");
            }else if(layEvent==="balance"){
                var urls="{:url('balance')}?id="+_id;
                lucky.CreateOpenForm("余额变动",urls);
            }
        });



        table.on('toolbar(table_id)', function(obj){
            var checkStatus = table.checkStatus(obj.config.id);
            var data = checkStatus.data;
            if(obj.event==="add"){
                lucky.CreateOpenForm("添加商户","{:url('add')}");
                return false;
            }else if(obj.event==="close"){
                opTables.closeAll();
            }else if(obj.event==="open"){
                opTables.openAll();
            }else if(obj.event==="reload"){
                lucky.CreateReload();
            }else if(obj.event==="del"){
                var num=0;
                var id=[];
                for (var i in data) {
                    num++;
                    id.push(data[i].id);
                }
                if (num<1) {
                    layer.msg("请选择一项",{time:1500});return false;
                }
                lucky.FormatData(id,"{:url('del')}");
                return  false;
            }
        });

        /**
         * 关键词搜索树
         */
        form.on('submit(search)', function (obj) {
            lucky.CreateSearch(obj.field);
            return false;
        });
    });

</script >

{/block}
